# Maintainer: Jelle van der Waa <jelle@archlinux.org>
# Contributor: Giovanni Harting <539@idlegandalf.com>

pkgname=python-awesomeversion
_name=${pkgname#python-}
pkgver=22.9.0
pkgrel=3
pkgdesc="One version package to rule them all."
arch=('any')
url="https://github.com/ludeeus/awesomeversion"
license=('MIT')
depends=(python)
makedepends=(python-build python-installer python-poetry-core)
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/ludeeus/$_name/archive/refs/tags/$pkgver.tar.gz")
sha512sums=('261849492c5d30b842c14376e065a35cf9ed716cbb7416828694a12a3a2120c922274604815db0953a56ad6bb5cff76276dc26d69aa03bd578321547107ffec1')

prepare() {
    cd $_name-$pkgver
    # version = "0"
    sed -e "s|version = \"0\"|version = \"$pkgver\"|" -i pyproject.toml
}

check() {
    cd $_name-$pkgver
    PYTHONPATH=. pytest tests
}

build() {
    cd $_name-$pkgver

    python -m build --wheel --no-isolation
}

package() {
    cd $_name-$pkgver

    python -m installer --destdir="$pkgdir" dist/*.whl
    install -Dm644 LICENCE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
